package com.qtummatrix.controller;

import com.opensymphony.xwork2.ActionSupport;
import com.opensymphony.xwork2.ModelDriven;
import com.qtummatrix.entity.BlackList;
import com.qtummatrix.service.BlacklistService;
import org.apache.struts2.ServletActionContext;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;

import javax.servlet.http.HttpServletRequest;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

@Controller("findBlacklistAudit")
public class BlacklistAuditController extends ActionSupport implements ModelDriven<BlackList>{
	@Autowired
	private BlacklistService blacklistService;

	Map<String,Object> info=new HashMap<String,Object>();


	public Map<String, Object> getInfo() {
		return info;
	}


	public void setInfo(Map<String, Object> info) {
		this.info = info;
	}

	private BlackList blackList =new BlackList();


	public BlackList getBlackList() {
		return blackList;
	}


	public void setBlackList(BlackList blackList) {
		this.blackList = blackList;
	}

	public BlackList getModel() {
		// TODO Auto-generated method stub
		return blackList;
	}

	public String findBlacklistAudit() {
		HttpServletRequest request =ServletActionContext.getRequest();

		String  page=request.getParameter("pageNo");//当前页数
		String rows=request.getParameter("pageSize");//当前条数

		List<BlackList> list1=blacklistService.findBlacklistAudit();
		int total=list1.size();//总条数

		//总页数
		int pages=total%Integer.parseInt(rows)==0?total/Integer.parseInt(rows)
				:total/Integer.parseInt(rows)+1;

		String name=blackList.getName();
		String source=blackList.getSource();

		String UID=blackList.getUID();
		String type=blackList.getType();
		List<BlackList> list=null;
		list=blacklistService.findBlacklistAudit(UID, name, source, type,(Integer.parseInt(page)-1)*Integer.parseInt(rows), Integer.parseInt(rows));
		info.put("list", list);
		info.put("pageNum", page);//当前页数
		info.put("pages", pages);//总页数
		info.put("total", total);//总条数

		return SUCCESS;
	}



}
